﻿<span style='font-size:11px; color:#000000; background:#ffffff; '><pre>
<span style='color:#800000; font-weight:bold; '>protected</span> <span style='color:#800000; font-weight:bold; '>void</span> createPdfButton_Click<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>object</span> sender<span style='color:#808030; '>,</span> EventArgs e<span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
    <span style='color:#696969; '>// Create a PDF document</span>
    Document pdfDocument <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> Document<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#696969; '>// Set license key received after purchase to use the converter in licensed mode</span>
    <span style='color:#696969; '>// Leave it not set to use the converter in demo mode</span>
    pdfDocument<span style='color:#808030; '>.</span>LicenseKey <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>

    <span style='color:#696969; '>// Add a page to PDF document</span>
    PdfPage pdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>try</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#696969; '>// The titles font used to mark various sections of the PDF document</span>
        PdfFont titleFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>new</span> Font<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Times New Roman</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> FontStyle<span style='color:#808030; '>.</span>Bold<span style='color:#808030; '>,</span> GraphicsUnit<span style='color:#808030; '>.</span>Point<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        PdfFont subtitleFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>AddFont<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>new</span> Font<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Times New Roman</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>8</span><span style='color:#808030; '>,</span> FontStyle<span style='color:#808030; '>.</span>Regular<span style='color:#808030; '>,</span> GraphicsUnit<span style='color:#808030; '>.</span>Point<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#800000; font-weight:bold; '>float</span> xLocation <span style='color:#808030; '>=</span> <span style='color:#008c00; '>5</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>float</span> yLocation <span style='color:#808030; '>=</span> <span style='color:#008c00; '>5</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add document title</span>
        TextElement titleTextElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Add Text Notes to a PDF Document</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        AddElementResult addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>titleTextElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>15</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        <span style='color:#800000; font-weight:bold; '>string</span> text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Click the next icon to open the the text note:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>float</span> textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        TextElement textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        RectangleF textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement textNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed text note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Note<span style='color:#800080; '>;</span>
        textNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an already opened text note:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement textNoteOpenedElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially opened text note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textNoteOpenedElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Note<span style='color:#800080; '>;</span>
        textNoteOpenedElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textNoteOpenedElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Click the next icon to open the the help note:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement helpNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed help note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        helpNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Help<span style='color:#800080; '>;</span>
        helpNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>helpNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an already opened help note:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement helpNoteOpenedElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially opened help note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        helpNoteOpenedElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Help<span style='color:#800080; '>;</span>
        helpNoteOpenedElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>helpNoteOpenedElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Click the next icon to open the comment:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement commentNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed comment note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        commentNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Comment<span style='color:#800080; '>;</span>
        commentNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>commentNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an already opened comment:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement commentNoteOpenedElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially opened comment note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        commentNoteOpenedElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Comment<span style='color:#800080; '>;</span>
        commentNoteOpenedElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>commentNoteOpenedElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Click the next icon to open the paragraph note: </span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement paragraphNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed paragraph note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        paragraphNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Paragraph<span style='color:#800080; '>;</span>
        paragraphNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>paragraphNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Click the next icon to open the new paragraph note:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement newParagraphNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed new paragraph note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        newParagraphNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>NewParagraph<span style='color:#800080; '>;</span>
        newParagraphNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>newParagraphNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        yLocation <span style='color:#808030; '>=</span> addElementResult<span style='color:#808030; '>.</span>EndPageBounds<span style='color:#808030; '>.</span>Bottom <span style='color:#808030; '>+</span> <span style='color:#008c00; '>10</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Add the text element</span>
        text <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>Click the next icon to open the key note:</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>
        textWidth <span style='color:#808030; '>=</span> subtitleFont<span style='color:#808030; '>.</span>GetTextWidth<span style='color:#808030; '>(</span>text<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        textElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextElement<span style='color:#808030; '>(</span>xLocation<span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> text<span style='color:#808030; '>,</span> subtitleFont<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        addElementResult <span style='color:#808030; '>=</span> pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        textNoteRectangle <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> RectangleF<span style='color:#808030; '>(</span>xLocation <span style='color:#808030; '>+</span> textWidth <span style='color:#808030; '>+</span> <span style='color:#008c00; '>1</span><span style='color:#808030; '>,</span> yLocation<span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>10</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Create the text note</span>
        TextNoteElement keyNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed key note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        keyNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Key<span style='color:#800080; '>;</span>
        keyNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
        pdfPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>keyNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Save the PDF document in a memory buffer</span>
        <span style='color:#800000; font-weight:bold; '>byte</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> outPdfBuffer <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Save<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Send the PDF as response to browser</span>

        <span style='color:#696969; '>// Set response content type</span>
        Response<span style='color:#808030; '>.</span>AddHeader<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Content-Type</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>application/pdf</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Instruct the browser to open the PDF file as an attachment or inline</span>
        Response<span style='color:#808030; '>.</span>AddHeader<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Content-Disposition</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> String<span style='color:#808030; '>.</span>Format<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>attachment; filename=Text_Notes.pdf; size={0}</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> outPdfBuffer<span style='color:#808030; '>.</span>Length<span style='color:#808030; '>.</span>ToString<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Write the PDF document buffer to HTTP response</span>
        Response<span style='color:#808030; '>.</span>BinaryWrite<span style='color:#808030; '>(</span>outPdfBuffer<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// End the HTTP response and stop the current page processing</span>
        Response<span style='color:#808030; '>.</span>End<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>finally</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#696969; '>// Close the PDF document</span>
        pdfDocument<span style='color:#808030; '>.</span>Close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</span>